package com.zzedu.controller;

import com.zzedu.common.annotation.Log;
import com.zzedu.common.core.controller.BaseController;
import com.zzedu.common.core.domain.AjaxResult;
import com.zzedu.common.core.page.TableDataInfo;
import com.zzedu.common.enums.BusinessType;
import com.zzedu.common.utils.ServletUtils;
import com.zzedu.common.utils.poi.ExcelUtil;
import com.zzedu.domain.ZzSchoolCourse;
import com.zzedu.dto.ZzSchoolCourseDTO;
import com.zzedu.service.IZzSchoolCourseService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * 学校解锁记录Controller
 * 
 * @author Mr.Wang
 * @date 2025-08-30
 */
@RestController
@RequestMapping("/school/classessendschool")
public class ZzSchoolCourseController extends BaseController
{
    @Autowired
    private IZzSchoolCourseService zzClassesSendSchoolService;

    /**
     * 查询学校解锁记录列表
     */
    @PreAuthorize("@permission.hasAnyPermissions('school:classessendschool:query')")
    @RequestMapping("/list")
    public TableDataInfo list(@RequestBody ZzSchoolCourseDTO zzClassesSendSchool)
    {
        return getDataTable(zzClassesSendSchoolService.page(zzClassesSendSchool.getPageDTO(),zzClassesSendSchoolService.buildQuery(zzClassesSendSchool)));
    }

    /**
     * 导出学校解锁记录列表
     */
    @PreAuthorize("@permission.hasAnyPermissions('school:classessendschool:export')")
    @Log(title = "学校解锁记录", businessType = BusinessType.EXPORT)
    @RequestMapping("/export")
    public void export(ZzSchoolCourseDTO zzClassesSendSchool)
    {
        List<ZzSchoolCourse> list = zzClassesSendSchoolService.list(zzClassesSendSchoolService.buildQuery(zzClassesSendSchool));
        ExcelUtil<ZzSchoolCourse> util = new ExcelUtil<ZzSchoolCourse>(ZzSchoolCourse.class);
        util.exportExcel(ServletUtils.getResponse(),list, "学校解锁记录数据");
    }




    /**
     * 新增保存学校解锁记录
     */
    @PreAuthorize("@permission.hasAnyPermissions('school:classessendschool:add')")
    @Log(title = "学校解锁记录", businessType = BusinessType.INSERT)
    @RequestMapping("/add")
    public AjaxResult addSave(@Validated @RequestBody ZzSchoolCourse zzSchoolCourse)
    {
        return toAjax(zzClassesSendSchoolService.save(zzSchoolCourse));
    }



    /**
     * 获取学校解锁记录详细信息
     */
    @PreAuthorize("@permission.hasAnyPermissions('school:classessendschool:query')")
    @RequestMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(zzClassesSendSchoolService.getById(id));
    }


    /**
     * 修改保存学校解锁记录
     */
    @PreAuthorize("@permission.hasAnyPermissions('school:classessendschool:edit')")
    @Log(title = "学校解锁记录", businessType = BusinessType.UPDATE)
    @RequestMapping("/edit")
    public AjaxResult editSave(@Validated @RequestBody ZzSchoolCourse zzSchoolCourse)
    {
        return toAjax(zzClassesSendSchoolService.updateById(zzSchoolCourse));
    }

    /**
     * 删除学校解锁记录
     */
    @PreAuthorize("@permission.hasAnyPermissions('school:classessendschool:remove')")
    @Log(title = "学校解锁记录", businessType = BusinessType.DELETE)
	@RequestMapping("/remove/{ids}")
    public AjaxResult remove(@PathVariable List<Long> ids)
    {
        return toAjax(zzClassesSendSchoolService.removeBatchByIds(ids));
    }
}
